{% extends 'layout/main.html' %}
{% from 'bootstrap/pagination.html' import render_pagination %}

{% block content_header %}
<h1> 栏目管理 </h1>
<ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="#">Examples</a></li>
    <li class="active">Blank page</li>
</ol>
{% endblock %}


{% block content %}
<div class="box">
    <div class="box-header with-border">
        <a class="btn btn-success btn-sm" href="{{ url_for('backend_categorys.create')}}">创建栏目</a>
        <div class="box-tools pull-right">
            <div class="has-feedback">
                <input type="text" class="form-control input-sm" placeholder="Search...">
                <span class="glyphicon glyphicon-search form-control-feedback text-muted"></span>
            </div>
        </div>
    </div>
    <div class="box-body">
        <div class="table-responsive">
            {% if model %}
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>名称</th>
                        <th>排序</th>
                        <th>添加时间</th>
                        <th class="action-column">操作</th>
                    </tr>
                    <tr class="filters">
                        <td>&nbsp;</td>
                        <td><input type="text" class="form-control" name="ContractSearch[name]"></td>
                        <td><input type="text" class="form-control" name="ContractSearch[salesman]"></td>
                        <td>&nbsp;</td>
                    </tr>
                </thead>
                <tbody>
                    {% for item in model %}
                    <tr>
                        <td>{{ loop.index + ((page - 1) * 20) }}</td>
                        <td>{{ item.name }}</td>
                        <td>{{ item.sort }}</td>
                        <td>{{ moment(item.created_at).format('L, ah:mm:ss') }}</td>
                        <td>
                            <a class="btn btn-default btn-sm" href="{{ url_for('backend_categorys.view', id=item.id) }}" title="查看"><span class="glyphicon glyphicon-eye-open"></span></a>
                            <a class="btn btn-default btn-sm" href="{{ url_for('backend_categorys.update', id=item.id) }}" title="更新"><span class="glyphicon glyphicon-pencil"></span></a>
                            <form action="{{ url_for('backend_categorys.delete', id=item.id) }}" method="post" class='inline'>

                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                                <button type="submit" class="btn btn-default btn-sm" onclick="return confirm('Are you sure?');"><span class="glyphicon glyphicon-trash"></span></button>

                            </form>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
            <p>无数据</p>
            {% endif %}
        </div>
    </div>
    <div class="box-footer">
        <div class="page-footer">{{ render_pagination(pagination) }}</div>
    </div>
</div>
{% endblock %}
